import paho.mqtt.client as mqtt

def on_connect(client,userdata,flag,rc):
    print("connect with mqtt server successfully")
    client.subscribe("sensor",qos=1)


mqttclient=mqtt.Client(client_id="Fhb2040707103",clean_session=False)


def mqtt_run():
    host="175.178.100.136"
    port=1883
    mqttclient.on_connect=on_connect
    mqttclient.connect(host,port)
    mqttclient.loop_start()

  
if __name__=="__main__":
    mqtt_run()